<!--
 * @Description: In User Settings Edit
 * @Author: your name
 * @Date: 2019-08-22 11:06:08
 * @LastEditTime: 2020-03-17 21:36:25
 * @LastEditors: Please set LastEditors
 -->
<!doctype html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport"
			content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
		<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
		<title>Hello APP</title>
		<link rel="stylesheet" type="text/css" href="../css/vant.css">
		<link rel="stylesheet" type="text/css" href="../css/base.css" />
		<link rel="stylesheet" type="text/css" href="../css/local.css" />
		<script type="text/javascript" src="../script/jquery.js"></script>
		<script type="text/javascript" src="../script/layer/mobile/layer.js"></script>
		<script type="text/javascript" src="../script/vue.min.js"></script>
		<script src="../script/vant.min.js"></script>
		<script type="text/javascript" src="../script/fastclick.js"></script>
		<script type="text/javascript" src="../script/base.js"></script>
		<style type="text/css">

		</style>
	</head>

	<body>
		<div id="app" v-cloak>
			<div class="init-full">
				<van-nav-bar class="head" title="公司信息" left-arrow @click-left="onClickLeft">
				</van-nav-bar>
				<div class="body-no-bottom">
					<div class="content">
						<van-cell-group>
							<van-field label="维修厂名称" v-model="userData.ClientName" placeholder="请输入维修厂名称"
								readonly></van-field>
							<van-field label="门头名称" v-model="userData.DoorWayName" placeholder="请输入门头名称"
								readonly></van-field>
							<van-field label="联系人名称" v-model="userData.LinkName" placeholder="请输入联系人名称"
								readonly></van-field>
							<van-field label="联系方式" type="tel" v-model="userData.LinkTelphone" placeholder="请输入联系方式"
								readonly>
							</van-field>
							<van-field label="地区" v-model="userData.area" placeholder="请选择省/市/区" readonly></van-field>
							<van-field label="详细地址" v-model="userData.Address" placeholder="请输入详细地址"
								readonly></van-field>
							<van-cell title="营业执照(正面)">
								<div style="padding:10px 0;">
									<div class="van-uploader">
										<div class="van-uploader__wrapper">
											<div class="van-uploader__preview"
												@click="previewImage(userData.LicenseImg)">
												<div class="van-image van-uploader__preview-image"
													style="overflow: hidden; border-radius: 4px;">
													<img :src="shoppingMallServerIP + userData.LicenseImg"
														class="van-image__img" style="object-fit: cover;" />
												</div>
											</div>
										</div>
									</div>
								</div>
							</van-cell>
							<van-cell title="门头照片">
								<div style="padding:10px 0;">
									<div class="van-uploader">
										<div class="van-uploader__wrapper">
											<div class="van-uploader__preview" v-if="userData.DoorWayImg1"
												@click="previewImage(userData.DoorWayImg1)">
												<div class="van-image van-uploader__preview-image"
													style="overflow: hidden; border-radius: 4px;">
													<img :src="shoppingMallServerIP + userData.DoorWayImg1"
														class="van-image__img" style="object-fit: cover;" />
												</div>
											</div>
											<div class="van-uploader__preview" v-if="userData.DoorWayImg2"
												@click="previewImage(userData.DoorWayImg2)">
												<div class="van-image van-uploader__preview-image"
													style="overflow: hidden; border-radius: 4px;">
													<img :src="shoppingMallServerIP + userData.DoorWayImg2"
														class="van-image__img" style="object-fit: cover;" />
												</div>
											</div>
											<div class="van-uploader__preview" v-if="userData.DoorWayImg3"
												@click="previewImage(userData.DoorWayImg3)">
												<div class="van-image van-uploader__preview-image"
													style="overflow: hidden; border-radius: 4px;">
													<img :src="shoppingMallServerIP + userData.DoorWayImg3"
														class="van-image__img" style="object-fit: cover;" />
												</div>
											</div>
										</div>
									</div>
								</div>
							</van-cell>
							<van-field label="邀请码" v-model="userData.RecommendCode" readonly></van-field>
						</van-cell-group>

					</div>
					<van-loading v-if="showLoading" />
				</div>
			</div>
		</div>
	</body>

	<!-- 调用 uniapp webview 的 api ，记得需要写在 body 标签下面 -->
	<script src="../../../assets/script/uni.webview.1.5.4.js"></script>
	<script type="text/javascript">
		var vm;
		//$('.init-full').show();


		vm = new Vue({
			el: '#app',
			data: {
				showLoading: false,
				ifConfirm: false,
				shoppingMallServerIP: 'http://' + FLD.shoppingMallServerIP,
				userData: ''
			},
			created: function() {
				var that = this;
				that.getEnterprise();
			},
			methods: {
				getDefualtArea() {
					var that = this;
					var texts = '';
					var fullregionpath = that.userData.RegionPath.split(',');
					FLD.ajax('sp_getRegion', {
						parentRegionId: 0
					}, function(res) {
						var row1 = res.ds.filter(function(item) {
							return item.RegionId == parseInt(fullregionpath[0]);
						})
						if (row1.length) {
							texts += row1[0].RegionName;
						}

						FLD.ajax('sp_getRegion', {
							parentRegionId: row1[0].RegionId
						}, function(res) {
							var row2 = res.ds.filter(function(item) {
								return item.RegionId == parseInt(fullregionpath[1]);
							})
							if (row2.length) {
								texts += row2[0].RegionName;
							}
							FLD.ajax('sp_getRegion', {
								parentRegionId: row2[0].RegionId
							}, function(res) {
								var row3 = res.ds.filter(function(item) {
									return item.RegionId == parseInt(
										fullregionpath[2]);
								})
								if (row3.length) {
									texts += row3[0].RegionName;
								}
								that.$set(that.userData, 'area', texts)

							})

						})

					})
				},
				getEnterprise() {
					var that = this;
					FLD.ajax('sp_getClientInfo', {}, function(res) {
						that.userData = res.ds[0];
						that.getDefualtArea()
					})
				},
				previewImage(img) {
					var http_img = shoppingMallServerIP + img;
					photoBrowser.open({
						images: [http_img],
						bgColor: '#000'
					}, function(ret) {
						if (ret) {
							if (ret.eventType == 'click') {
								photoBrowser.close();
							}
						}
					})
				},
				onClickLeft() {
					uni.navigateBack()
				}
			}
		})
	</script>

</html>